8037d5d4: 27 bd ff d8  ADDIU sp, sp, 0xffffffd8 (-40)
8037d5d8: af bf 00 1c  SW ra, sp, 0x1c (28)

8037d5dc: 3c 0e 80 39  LUI t6, 0x8039 (32825)
8037d5e0: 8d ce bd 80  LW t6, t6, 0xffffbd80 (-17024)          t6 = *(0x8038bd80)
8037d5e4: 3c 04 80 39  LUI a0, 0x8039 (32825)
8037d5e8: 8c 84 bc a0  LW a0, a0, 0xffffbca0 (-17248)
8037d5ec: 8d cf 00 04  LW t7, t6, 0x4 (4)                      t7 = *(0x8038bd80)->off0x04
8037d5f0: 85 c6 00 02  LH a2, t6, 0x2 (2)
8037d5f4: af a0 00 14  SW r0, sp, 0x14 (20)
8037d5f8: 00 00 28 25  OR a1, r0, r0
8037d5fc: 00 00 38 25  OR a3, r0, r0
8037d600: 0c 0d ed 6d  JAL 0x8037b5b4 (-2143832652)        [sp + 0x24] = 0x8037b5b4(*(0x8038bca0), 0, *(0x8038bd80)->off0x02, 0, *(0x8038bd80)->off0x04, 0);
8037d604: af af 00 10  SW t7, sp, 0x10 (16)
8037d608: af a2 00 24  SW v0, sp, 0x24 (36)

8037d60c: 0c 0d f3 1d  JAL 0x8037cc74 (-2143826828)        0x8037cc74([sp + 0x24]);
8037d610: 8f a4 00 24  LW a0, sp, 0x24 (36)

8037d614: 3c 18 80 39  LUI t8, 0x8039 (32825)
8037d618: 8f 18 bd 80  LW t8, t8, 0xffffbd80 (-17024)
8037d61c: 3c 01 80 39  LUI at, 0x8039 (32825)
8037d620: 27 19 00 08  ADDIU t9, t8, 0x8 (8)
8037d624: ac 39 bd 80  SW t9, at, 0xffffbd80 (-17024)      *(0x8038bd80) += 0x08;

8037d628: 10 00 00 01  BEQ r0, r0, 0x8037d630 (pc + 0x4)
8037d62c: 00 00 00 00  NOP
8037d630: 8f bf 00 1c  LW ra, sp, 0x1c (28)
8037d634: 27 bd 00 28  ADDIU sp, sp, 0x28 (40)
8037d638: 03 e0 00 08  JR ra
8037d63c: 00 00 00 00  NOP

///////////////////////////////////////


8037b5b4: 27 bd ff e8  ADDIU sp, sp, 0xffffffe8 (-24)
8037b5b8: af bf 00 14  SW ra, sp, 0x14 (20)
8037b5bc: af a4 00 18  SW a0, sp, 0x18 (24)                    [sp + 0x18] === arg1
8037b5c0: af a5 00 1c  SW a1, sp, 0x1c (28)                    [sp + 0x1c] === arg2
8037b5c4: af a6 00 20  SW a2, sp, 0x20 (32)                    [sp + 0x22] === arg3
8037b5c8: af a7 00 24  SW a3, sp, 0x24 (36)                    [sp + 0x26] === arg4
                                                               [sp + 0x28] === arg5
                                                               [sp + 0x2c] === arg6

8037b5cc: 8f ae 00 18  LW t6, sp, 0x18 (24)
8037b5d0: 11 c0 00 05  BEQ r0, t6, 0x8037b5e8 (pc + 0x14)  if (!arg1) goto 0x8037b5e8;
8037b5d4: 00 00 00 00  NOP

8037b5d8: 8f a4 00 18  LW a0, sp, 0x18 (24)
8037b5dc: 0c 09 e2 ae  JAL 0x80278ab8 (-2144892232)        arg2 = 0x80278ab8(arg1, 0x20);
8037b5e0: 24 05 00 20  ADDIU a1, r0, 0x20 (32)
8037b5e4: af a2 00 1c  SW v0, sp, 0x1c (28)

*
8037b5e8: 8f af 00 1c  LW t7, sp, 0x1c (28)
8037b5ec: 11 e0 00 18  BEQ r0, t7, 0x8037b650 (pc + 0x60)  if (!arg2) goto 0x8037b650;
8037b5f0: 00 00 00 00  NOP

8037b5f4: 8f a4 00 1c  LW a0, sp, 0x1c (28)
8037b5f8: 0c 0d ec 88  JAL 0x8037b220 (-2143833568)        0x8037b220(arg2, 0x10c);
8037b5fc: 24 05 01 0c  ADDIU a1, r0, 0x10c (268)

8037b600: 87 b8 00 22  LH t8, sp, 0x22 (34)
8037b604: 8f b9 00 1c  LW t9, sp, 0x1c (28)
8037b608: a7 38 00 1c  SH t8, t9, 0x1c (28)                arg2->off0x1c = arg3;

8037b60c: 87 a8 00 26  LH t0, sp, 0x26 (38)
8037b610: 8f a9 00 1c  LW t1, sp, 0x1c (28)
8037b614: a5 28 00 1e  SH t0, t1, 0x1e (30)                arg2->off0x1e = arg4;

8037b618: 8f aa 00 28  LW t2, sp, 0x28 (40)
8037b61c: 8f ab 00 1c  LW t3, sp, 0x1c (28)
8037b620: ad 6a 00 14  SW t2, t3, 0x14 (20)                arg2->off0x14 = arg5;

8037b624: 8f ac 00 2c  LW t4, sp, 0x2c (44)
8037b628: 8f ad 00 1c  LW t5, sp, 0x1c (28)
8037b62c: ad ac 00 18  SW t4, t5, 0x18 (24)                arg2->off0x18 = arg6;

8037b630: 8f ae 00 28  LW t6, sp, 0x28 (40)
8037b634: 11 c0 00 06  BEQ r0, t6, 0x8037b650 (pc + 0x18)  if (!arg5) goto 0x8037b650;
8037b638: 00 00 00 00  NOP

8037b63c: 8f b9 00 28  LW t9, sp, 0x28 (40)
8037b640: 00 00 20 25  OR a0, r0, r0
8037b644: 8f a5 00 1c  LW a1, sp, 0x1c (28)
8037b648: 03 20 f8 09  JALR t9, ra                         arg5(0, arg2, arg1);
8037b64c: 8f a6 00 18  LW a2, sp, 0x18 (24)

**
8037b650: 10 00 00 03  BEQ r0, r0, 0x8037b660 (pc + 0xc)
8037b654: 8f a2 00 1c  LW v0, sp, 0x1c (28)                return arg2;
8037b658: 10 00 00 01  BEQ r0, r0, 0x8037b660 (pc + 0x4)
8037b65c: 00 00 00 00  NOP
8037b660: 8f bf 00 14  LW ra, sp, 0x14 (20)
8037b664: 27 bd 00 18  ADDIU sp, sp, 0x18 (24)
8037b668: 03 e0 00 08  JR ra
8037b66c: 00 00 00 00  NOP

typedef struct tagLAYOUT_NODE_0x10C {
    struct tagLAYOUT_NODE node;                                       /* 0x14 @ 0x00 */
    void (*func)(int, LAYOUT_NODE_0x10c *, struct allocation_stack);  /*    4 @ 0x14 - function to call for this node */
    u32 a;                                                            /*    4 @ 0x18 - init'd to zero */
    short b;                                                          /*    2 @ 0x1c - set from offset 2 in the command */
    short chosen_child;                                               /*    2 @ 0x1e - init'd to zero */
} LAYOUT_NODE_0x10C;


proc_0x8037b5b4(struct allocation_stack *arg1, LAYOUT_NODE_0x10c *arg2, short arg3, short arg4, void (*arg5)(int, LAYOUT_NODE_0x10c *, struct allocation_stack), u32 arg6)
{
    if (arg1) {
        arg2 = 0x80278ab8(arg1, 0x20);
    }
    if (arg2) {
        0x8037b220(arg2, 0x10c);
        arg2->off0x1c = arg3;
        arg2->off0x1e = arg4;
        arg2->off0x14 = arg5;
        arg2->off0x18 = arg6;
        if (arg5) {
            arg5(0, arg2, arg1);
        }
    }
    return arg2;
}
